Skip to content

Structured Logs: Buffering & flushing of logs #5628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 21, 2025

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Jul 14, 2025

#skip-changelog

📜 Description

Implements batching of logs.

  • Dispatch by 5 seconds
  • Dispatch immediately if 100 logs are scheduled.

💡 Motivation and Context

Closes #5580

💚 How did you test it?

Unit tests

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@denrase denrase changed the title Structured Logs: Logs Batcher Structured Logs: Buffering & flushing of logs Jul 14, 2025
@denrase denrase marked this pull request as ready for review July 14, 2025 15:30
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 98.01980% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.692%. Comparing base (6ee4973) to head (8290c16).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ntryTestUtils/TestSentryDispatchQueueWrapper.swift 91.666% 1 Missing ⚠️
Sources/Swift/Tools/SentryLogBatcher.swift 98.701% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #5628       +/-   ##
=============================================
+ Coverage   86.631%   86.692%   +0.061%     
=============================================
  Files          419       419               
  Lines        35717     35808       +91     
  Branches     16869     16921       +52     
=============================================
+ Hits         30942     31043      +101     
+ Misses        4731      4723        -8     
+ Partials        44        42        -2     
Files with missing lines Coverage Δ
SentryTestUtils/TestClient.swift 84.552% <100.000%> (ø)
Sources/Sentry/SentryClient.m 98.501% <100.000%> (+0.002%) ⬆️
Sources/Sentry/SentrySDK.m 87.914% <100.000%> (+0.057%) ⬆️
...rces/Swift/Helper/SentryDispatchQueueWrapper.swift 100.000% <100.000%> (ø)
...ntryTestUtils/TestSentryDispatchQueueWrapper.swift 89.855% <91.666%> (+0.381%) ⬆️
Sources/Swift/Tools/SentryLogBatcher.swift 98.850% <98.701%> (+4.406%) ⬆️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ee4973...8290c16. Read the comment docs.

Copy link
Contributor

github-actions bot commented Jul 14, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1221.42 ms 1249.02 ms 27.60 ms
Size 23.75 KiB 902.02 KiB 878.27 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
2b02431 1229.63 ms 1248.98 ms 19.35 ms
2481950 1221.04 ms 1248.98 ms 27.94 ms
e3ebff3 1223.47 ms 1249.27 ms 25.80 ms
30f4e4c 1213.21 ms 1250.29 ms 37.08 ms
fc0757d 1231.83 ms 1248.98 ms 17.15 ms
7148f97 1235.09 ms 1258.07 ms 22.98 ms
4e3915a 1230.02 ms 1258.90 ms 28.88 ms
7d23639 1237.93 ms 1243.04 ms 5.11 ms
aa96485 1215.37 ms 1234.04 ms 18.67 ms
a9fac2e 1212.45 ms 1219.67 ms 7.22 ms

App size

Revision Plain With Sentry Diff
2b02431 23.75 KiB 850.73 KiB 826.98 KiB
2481950 23.74 KiB 872.74 KiB 849.00 KiB
e3ebff3 23.75 KiB 878.48 KiB 854.73 KiB
30f4e4c 23.75 KiB 879.24 KiB 855.50 KiB
fc0757d 23.75 KiB 850.73 KiB 826.98 KiB
7148f97 23.75 KiB 854.78 KiB 831.03 KiB
4e3915a 23.75 KiB 858.69 KiB 834.94 KiB
7d23639 23.75 KiB 891.01 KiB 867.26 KiB
aa96485 23.75 KiB 874.46 KiB 850.71 KiB
a9fac2e 23.75 KiB 879.53 KiB 855.78 KiB

Previous results on branch: feat/structured-logs-batcher

Startup times

Revision Plain With Sentry Diff
023fb2c 1216.98 ms 1243.15 ms 26.17 ms
482b03d 1230.06 ms 1250.23 ms 20.17 ms

App size

Revision Plain With Sentry Diff
023fb2c 23.75 KiB 893.04 KiB 869.29 KiB
482b03d 23.75 KiB 901.08 KiB 877.34 KiB

Copy link
Contributor

@itaybre itaybre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but added a question we might want to answer

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @denrase, but I found some issues. It could be that the develop docs in https://develop.sentry.dev/sdk/telemetry/spans/batch-processor/#specification need some clarification. Please let me know if they aren't clear enough and I will update them.

@denrase denrase requested a review from philipphofmann July 17, 2025 14:30
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, for including the feedback. We're getting close.

@denrase denrase requested a review from philipphofmann July 18, 2025 09:39
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final comment to address. Thank you @denrase. Then LGTM.

denrase added 2 commits July 18, 2025 14:00
# Conflicts:
#	Sources/Swift/Tools/SentryLogBatcher.swift
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@denrase denrase merged commit fac4ca3 into main Jul 21, 2025
181 of 189 checks passed
@denrase denrase deleted the feat/structured-logs-batcher branch July 21, 2025 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Structured Logs: Buffering & flushing of logs
3 participants